package simulation;

import java.util.List;

import util.Location;
import util.Vector;

public class InverseProportionalCenterOfMass extends CenterOfMass {
	public InverseProportionalCenterOfMass(double magnitude){
		super(magnitude);
	}
	
	public void apply(List<Mass> Masses){
		if (!isOn()) 
			return;
		Location center=calculateCenter(Masses);
		for (Mass m:Masses){
			Vector theForce=new Vector(m.getCenter(),center);
			Vector adjustedForce=new Vector(theForce.getDirection(),1/theForce.getMagnitude()*getMagnitude());
			m.applyForce(adjustedForce);
		}
		
		
	}

}
